<template>
  <div class="boss">
    <head-page
      :title="`${list.title}(${this.$route.query.id})`"
      class="head-page" 
      id="back"
    ></head-page>
    <div class="center">
      <!-- 省会内容总区域  -->
      <div class="shenghui" v-if="list.text && list.text.length">
        <!-- 省会区域 -->
        <div class="small" v-for="(item, index) in list.text" :key="index">
          <!-- 原点区域 -->
          <div class="left">
            <img src="../../../assets/diamondbalck.png" alt="" />
          </div>
          <!-- 内容区域 -->
          <div class="right" @click="newdetail(item.newsId)">
            {{ item.newsTitle }}
          </div>
        </div>
      </div>
      <div v-else class="p-20 tac">暂无数据</div>
    </div>
  </div>
</template>
  
  <script>
import { newsTitlesGuonei, AllnewsType } from "@/api/index";
export default {
  data() {
    return {
      list: {
        title: "",
        text: [],
      },
    };
  },

  mounted() {
    //国内新闻标题(除定位出来所有的数据)
    if (this.$route.query.newtype == "国内新闻") {
      AllnewsType(this.$route.query.newtype, this.$route.query.id).then(
        (res) => {
          if (res.data.code == 200) {
            if (res.data.rows == "") {
            } else {
              this.list.text = res.data.rows;
              this.list.title = res.data.rows[0].fatherId;
            }
          }
        }
      );
    } else if (this.$route.query.newtype == "国际新闻") {
      //国际新闻标题
      AllnewsType(this.$route.query.newtype, this.$route.query.id).then(
        (res) => {
          if (res.data.code == 200) {
            if (res.data.rows == "") {
            } else {
              this.list.text = res.data.rows;
              this.list.title = res.data.rows[0].fatherId;
            }
          }
        }
      );
    } else {
      //国内新闻标题(福建)
      newsTitlesGuonei(this.$route.query.id).then((res) => {
        if (res.data.code == 200) {
          if (res.data.data == "") {
          } else {
            this.list.text = res.data.data;
            this.list.title = res.data.data[0].fatherId;
          }
        }
      });
    }
  },
  methods: {
    //新闻详情
    newdetail(id) {
      this.$router.push({ path: "/newsthree/shangDetail", query: { id } });
      //  console.log(id);
    },
  },
};
</script>
  
  <style scoped>
.boss {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.head-page {
  border-bottom: none;
}
/* 版心区域 */
.center {
  width: 98%;
  min-height: 2rem;
  margin-top: 0.12rem;
}
/* 关注各省的标题 */
.guan {
  height: 0.4rem;
  text-align: center;
  line-height: 0.4rem;
  font-size: 20px;
}
/* 省会总区域 */
.shenghui {
  width: 100%;
}
/* 省会区域 */
.small {
  width: 100%;
  display: flex;
  margin-bottom: 0.07rem;
}
/* 原点区域 */
.left {
  width: 5.5%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.left img {
  width: 0.2rem;
  height: 0.2rem;
}
/* 内容区域 */
.right {
  width: 94%;
  height: 100%;
  padding-left: 0.05rem;
  font-weight: 700;
}
</style>